package com.yhq.spring.xml;

import com.yhq.spring.xml.service.*;
import lombok.SneakyThrows;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.concurrent.TimeUnit;

/**
 * @author hqyin
 * @date 2023/1/30 10:39 上午
 */
public class XmlTest {
    @SneakyThrows
    public static void main(String[] args) {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("test.xml");
        //测试父子BeanDefinition
//        ChildService childService = (ChildService) context.getBean("childService");
//        System.out.println(childService.getId()+":"+childService.getName());

        //测试FactoryBean
        EmployeeDTO manager = (EmployeeDTO) context.getBean("manager");
        System.out.println(manager);

        EmployeeDTO director = (EmployeeDTO) context.getBean("director");
        System.out.println(director);

        EmployeeFactoryBean factory = (EmployeeFactoryBean) context.getBean("&director");

        System.out.println(factory.getDesignation());
        System.out.println(factory.getObjectType());
        System.out.println(factory.getObject());


        //
//        UserService userService = (UserService) context.getBean("userService1");
//        userService.test();
//        UserService userService1 = (UserService) context.getBean("userService1");
//        userService1.test();
//        PersonService personService = (PersonService) context.getBean("personService");
//        personService.test();
    }
}
